﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SLPropertyGrid
{
    public class Helper
    {
        public static IList<DependencyObject>  ExploreVisualTree(DependencyObject root, Predicate<DependencyObject> predicate)
        {
            List<DependencyObject> ret = new List<DependencyObject>();
            int children = VisualTreeHelper.GetChildrenCount(root);
            for(int i =0;i<children;++i)
            {
                DependencyObject o = VisualTreeHelper.GetChild(root, i);
                if(predicate(o))
                    ret.Add(o);
                ret.AddRange(ExploreVisualTree(o,predicate));
            }
            return ret;
        }
    }
}
